/**
 * Created by lvliqi on 2016/7/12.
 */
/*
 秒秀脚法
 扫码
 点击开始
 ipad输入结果
 丫丫
 */

var express = require("express");
var router = express.Router();
var status_enum = require("../status_enum");
var activity_enum = require("./activity_enum");
var activityId = activity_enum.FREE_KICK;

router.post("/check", function (req, res) {
    var Queue = M("index.queue");

    Queue.find({
        where: {
            activityId: activityId,
            status: status_enum.PLAY_BTN
        }
    }).then(function (data) {
        if (!data) throw new Error("no data");
        return Queue.update({
            status: status_enum.PLAYING
        }, {
            where: {
                id: data.id
            }
        });
    }).then(function () {
        return res.send('1');
    }).catch(function (err) {
        console.log(err);
        res.send('0');
    });
});

module.exports = router;